<template>
	<view :style="$theme.pageStyle">
		<view class='cash-withdrawal'>
			<view class="header">
				<view class="headerCon" style="height: 164px;">
					<view class="money">{{ User.user_money }}</view>
					<view>可提现金额</view>
				</view>
			</view>
			<view class='wrapper'>
				<view class="nav acea-row">
					<view class="item on1">
						提现到微信
					</view>
					<view class="navBg on1"></view>
				</view>
				<view>
					<form @submit="getCash">
						<view class='list'>
							<view class="itemCon">
								<view class='item acea-row row-between-wrapper'>
									<view class='name'>提现</view>
									<view class='input acea-row row-between-wrapper'>
										<input v-model='cashVal' :maxlength="moneyMaxLeng"
											:placeholder='"最低提现金额：¥"+ config.low ' placeholder-class='placeholder'
											name="money" type='digit' />
										<view class="all" @click="allCash">全部提现</view>
									</view>
								</view>
							</view>
						
							
							<view class='item acea-row row-top row-between'>
								<view class='name'>收款码</view>
								<view class="input acea-row">
									<u--image :src="qrcodeUrlW" width="66px" height="66px"
										@tap="chooseimage"></u--image>
									<!-- <view class="picEwm" v-if="qrcodeUrlW">
										<image :src="qrcodeUrlW"></image>
										<text class='iconfont icon-ic_close fontcolor' @click='DelPicW'></text>
									</view>
									<view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("W")'
										v-else>
										<text class='iconfont icon-ic_camera'></text>
										<view>上传图片</view>
									</view> -->
								</view>
							</view>
							
							
							
							<view class='tip'>
								当前可提现金额: <text class="price">￥{{ User.user_money }}</text>
							</view>
							<view class='tip'>
								提现手续费: <text class="price">{{config.handling}} %</text>
							</view>
							<view class='tip'>
								说明: 单次最高提现: <text class="price">￥{{ config.height }}</text> 最低 <text
									class="price">￥{{ config.low }}</text>
							</view>
							 <view class="tip" @click="ToLog()" style="color: #666;font-size: 14px;margin-top: 15px;">查看提现记录</view>
						</view>
						<button formType="submit" style="background: var(--color-primary);" class='bnt bg-color'>立即提现</button>
						
					</form>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import $H from '@/common/js/request.js';
	export default {
		components: {},
		data() {
			return {
				TopHeight: uni.getStorageSync('TopHeight'),
				User: {},
				config: {},
				navList: [{
					'name': '提现至微信',
					'id': 1,
					key: 'user_extract_wechat_status',
					status: 1
				}],
				currentTab: '',
				index: 0,
				array: [], //提现银行
				minPrice: 0.00, //最低提现金额
				userInfo: [],
				isClone: false,
				isAuto: false, //没有授权的不会自动授权
				isShowAuth: false, //是否隐藏授权
				qrcodeUrlW: "",
				qrcodeUrlZ: "",
				prevent: true, //避免重复提交成功多次
				moneyMaxLeng: 8,
				withdraw_fee: '0',
				true_money: 0,
				extract_wechat_type: 0,
				cashVal: ''
			};
		},
		onLoad() {

		},
		onShow() {
			this.getUserInfo();
		},
		methods: {
			getUserInfo() {
				$H.post('distribution/cashindex', {

				}, {
					token: true
				}).then(res => {
					this.User = res.data.user
					this.config = res.data.config
				})
			},
			goarrow() {
				uni.navigateBack()
			},
			allCash() {
				this.cashVal = '';
				this.cashVal = this.User.user_money;
			},
			getCash() {
				
				
				
				$H.post('Withdraw/withdrawalApplication', {
					money : this.cashVal,
					image:  this.imgs,
					type : 1,
				}, {
					token: true
				}).then(res => {
					uni.showToast({
						icon: 'none',
						title: res.msg
					})
					this.getUserInfo();
				})
			},
			chooseimage() {
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: (res) => {
						var imageSrc = res.tempFilePaths[0];
						var token = uni.getStorageSync('token')
						uni.uploadFile({
							url: this.$url + 'upload/image',
							filePath: imageSrc,
							header:{ token },
							name: 'file',
							fileType: 'image',
							success: (res) => {
								if (res.code = 1) {
									let data = JSON.parse(res.data)
									this.imgs = data.data.uri
									this.qrcodeUrlW = data.data.uri
									setTimeout(() => {
										
									}, 500)
								}
							}
						});
					},
					fail: (err) => {
						console.log('chooseImage fail', err)
					}
				});
			},
			ToLog(){
				uni.navigateTo({
					url: '/distribution/user/cashlog'
				})
			}
		}
	}
</script>

<style lang="scss">
	.cash-withdrawal {
		.accountTitle {
			background: linear-gradient(90deg, var(--color-primary) 0%, #4dbaff 100%);
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			z-index: 99;

			.sysTitle {
				width: 100%;
				position: relative;
				font-weight: 500;
				color: #fff;
				font-size: 30rpx;

				.iconfont {
					position: absolute;
					font-size: 36rpx;
					left: 11rpx;
					width: 60rpx;
				}
			}
		}

		.header {
			width: 100%;
			// height: 380rpx;
			background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-light-3) 100%);
			font-size: 30rpx;
			font-weight: 400;
			color: #F5F5F5;
			text-align: center;
			padding-top: 88rpx;
			position: relative;

			&::after {
				position: absolute;
				content: ' ';
				width: 50%;
				height: 160rpx;
				background: linear-gradient(180deg, var(--color-primary-light-3) 0%, var(--color-primary-light-7) 100%);
				left: 0;
			}

			&:before {
				position: absolute;
				content: ' ';
				width: 50%;
				height: 160rpx;
				background: linear-gradient(180deg, var(--color-primary-light-7) 0%, var(--color-primary-light-7) 100%);
				right: 0;
				bottom: -146rpx;
			}

			.headerCon {
				background-image: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/131713588973NvT6g2.png');
				background-repeat: no-repeat;
				background-size: 100% 100%;
				width: 100%;
				height: 278rpx;
			}

			.money {
				font-size: 76rpx;
				font-weight: 600;
				color: #FFFFFF;
				font-family: 'Regular';
				margin-bottom: 16rpx;
			}
		}
	}

	.cash-withdrawal .wrapper {
		width: 710rpx;
		margin: -100rpx auto 0 auto;
		position: relative;
		z-index: 9;

		.nav {
			width: 100%;
			height: 110rpx;
			background-color: rgba(255, 255, 255, 0.9);
			border-radius: 24rpx 24rpx 0 0;
			position: relative;
			z-index: 9;

			&.on {
				height: unset;
				padding: 36rpx 0 28rpx 0;
				background-color: #fff;

				.item {
					padding-top: 0;
					padding-left: 30rpx;
					font-weight: 600;
				}
			}

			.item {
				width: 33.33%;
				padding: 22rpx 0 0 36rpx;
				color: #666666;
				font-size: 26rpx;
				position: relative;
				z-index: 9;

				&.on {
					width: 50%;
					padding-left: 0;
					text-align: center;
				}

				&.ons {
					color: var(--color-primary);
					font-weight: 600;
				}

				&.on1 {
					color: var(--color-primary);
					font-weight: 600;
				}

				&.on2 {
					color: var(--color-primary);
					text-align: center;
					padding-left: 0;
					font-weight: 600;
				}

				&.on3 {
					color: var(--color-primary);
					text-align: center;
					padding-left: 5px;
					font-weight: 600;
				}
			}

			.navBg {
				position: absolute;
				background-repeat: no-repeat;
				background-size: 100% 100%;
				width: 710rpx;
				height: 122rpx;
				left: 0;
				bottom: 0;
				box-sizing: border-box;

				&.on1 {
					background-image: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/121713588852GvcVZ7.png');
				}

				&.on2 {
					background-image: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/331713588933AQtVhq.png');
				}

				&.on3 {
					background-image: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/401713588940OqurAr.png');
				}

				&.on4 {
					background-image: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/4617135889462QbQca.png');
				}

				&.on5 {
					background-image: url('https://jiangxinsaas.oss-cn-beijing.aliyuncs.com/tuchuang/521713588952jhAYTN.png');
				}
			}
		}

		.bnt {
			font-size: 28rpx;
			color: #fff;
			width: 710rpx;
			height: 88rpx;
			text-align: center;
			border-radius: 50rpx;
			line-height: 88rpx;
			margin: 48rpx auto;
		}
	}

	.cash-withdrawal .wrapper .list {
		padding: 0 30rpx 48rpx 30rpx;
		background-color: #fff;
		border-radius: 0 0 24rpx 24rpx;

		.itemCon {
			border-bottom: 1px solid #EEEEEE;
			padding-bottom: 15rpx;
			margin-bottom: 42rpx;
		}
	}

	.cash-withdrawal .wrapper .list .item {
		font-size: 28rpx;
		color: #333;
		padding: 28rpx 0;
	}

	.cash-withdrawal .wrapper .list .item .name {
		width: 130rpx;
	}

	.cash-withdrawal .wrapper .list .item .input {
		width: 505rpx;

		input {
			font-size: 28rpx;
		}

		.iconfont {
			color: #ccc;
		}

		.icon-ic_camera {
			font-size: 38rpx;
			margin-bottom: 6rpx;
		}

		.all {
			font-size: 26rpx;
			color: var(--color-primary);
		}
	}

	.cash-withdrawal .wrapper .list .item .input .placeholder {
		color: #ccc;
	}

	.cash-withdrawal .wrapper .list .item .picEwm,
	.cash-withdrawal .wrapper .list .item .pictrue {
		width: 128rpx;
		height: 128rpx;
		border-radius: 14rpx;
		position: relative;
		margin-right: 23rpx;
		background: #F5F5F5;
	}

	.cash-withdrawal .wrapper .list .item .picEwm image {
		width: 100%;
		height: 100%;
		border-radius: 3rpx;
	}

	.cash-withdrawal .wrapper .list .item .picEwm .icon-ic_close {
		position: absolute;
		right: 0;
		top: 0;
		font-size: 24rpx;
		width: 32rpx;
		height: 32rpx;
		background: #999999;
		border-radius: 0 16rpx 0 16rpx;
		color: #fff;
		text-align: center;
		line-height: 32rpx;
	}

	.cash-withdrawal .wrapper .list .item .pictrue {
		font-size: 22rpx;
		color: #BBBBBB;
	}

	.cash-withdrawal .wrapper .list .item .pictrue .icon-icon25201 {
		font-size: 47rpx;
		color: #DDDDDD;
		margin-bottom: 3px;
	}

	.cash-withdrawal .wrapper .list .tip {
		font-size: 24rpx;
		color: #999;
		margin-top: 16rpx;

		.price {
			color: var(--color-primary);
			margin: 0 16rpx;
		}

		.num {
			margin-left: 16rpx;
		}
	}

	.cash-withdrawal .wrapper .list .tip2 {
		font-size: 26rpx;
		color: #999;
		text-align: center;
		margin: 44rpx 0 20rpx 0;
	}

	.cash-withdrawal .wrapper .list .value {
		height: 135rpx;
		line-height: 135rpx;
		border-bottom: 1rpx solid #eee;
		width: 690rpx;
		margin: 0 auto;
	}

	.cash-withdrawal .wrapper .list .value input {
		font-size: 80rpx;
		color: #282828;
		height: 135rpx;
		text-align: center;
	}

	.cash-withdrawal .wrapper .list .value .placeholder2 {
		color: #bbb;
	}

	.bg-gray {
		background-color: var(--color-primary);
		opacity: 0.4;
	}

	.acea-row {
		display: flex;
		flex-wrap: wrap;
	}

	.acea-row.row-between-wrapper {
		align-items: center;
		justify-content: space-between;
	}
</style>